package NGuessNumber;

import java.util.Scanner;

import javax.swing.JOptionPane;

public class NGuessNumber extends NguessNumberText {
	static int Rn[] = Rn();
	static Scanner is = new Scanner(System.in);

	public static void main(String[] args) {
		// generateAnswerTest(); // 验证
		JOptionPane.showMessageDialog(null, "电脑随机生成了一个0~9之间的数，请猜出这个数\n您一共有5次机会", "猜数字游戏", JOptionPane.PLAIN_MESSAGE);

		boolean Key = true;
		int sun = 0;
		do {
			int In[] = In();
			JOptionPane.showMessageDialog(null,
					"第" + (sun + 1) + "次机会\n" + "您刚刚猜对了" + NGuessNumber.generateAnswer(Rn, In) + "个数字", "猜数字游戏",
					JOptionPane.PLAIN_MESSAGE);
			sun++;
			Print(Rn, (generateAnswer(Rn, In)));
			if ((generateAnswer(Rn, In)) == 4) {
				break;
			}
			if (sun < 5) {
				continue;
			} else
				sun = 0;
			JOptionPane.showMessageDialog(null, "Gameover", "猜数字游戏", JOptionPane.PLAIN_MESSAGE);
			String number = (String) JOptionPane.showInputDialog(null, "正确答案为：" + right(Rn) + "是否在玩一次（Y/N）", "猜数字游戏",
					JOptionPane.PLAIN_MESSAGE, null, null, "");
			System.out.println("是否继续（Y/N）");
			if (number.equals("Y") || number.equals("y")) {
				Key = true;
				Rn();
			} else
				Key = false;
		} while (Key);
	}

}